// 统一管理用户相关接口
import request from '@/utils/request'
import type {
  LoginFormData,
  LoginResponseData,
  userInfoResponseData,
  ResponseData,
  RegisterFormData,
} from './type'

enum API {
  LOGIN_URL = 'sysUser/login',
  USERINFO_URL = 'sysUser/userInfo',
  LOGOUT_URL = 'sysUser/logout',
  REGISTER_URL = 'sysUser/register',
  ALLUSER_URL = '/sysUser/getAllUsers',
  ALLUSERLIST_URL = '/sysUser/getAllUsersList',
}

export const reqLogin = (data: LoginFormData) =>
  request.post<any, userInfoResponseData>(API.LOGIN_URL, data)

export const reqUserInfo = () =>
  request.get<any, userInfoResponseData>(API.USERINFO_URL)

export const reqLogOut = () => request.delete<any, any>(API.LOGOUT_URL)

export const reqRegister = (data: RegisterFormData) =>
  request.post<any, ResponseData>(API.REGISTER_URL, data)
